package com.bilin.coin.activity;

import android.graphics.drawable.Drawable;
import android.text.Html;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.bilin.coin.R;
import com.bilin.coin.common.base.BaseAppCompatActivity;

import java.net.URL;

import butterknife.BindView;

@Route(path = "/auction/NewsDetailActivity")
public class NewsDetailActivity extends BaseAppCompatActivity {

    @Autowired
    String content;

    @BindView(R.id.tv_content)
    TextView tv_content;

    @Override
    protected void initView() {
        setTitle("详情");

        tv_content.setText(Html.fromHtml(content,imageGetter,null));
    }

    @Override
    protected void initData() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_news_detail;
    }


    final Html.ImageGetter imageGetter = new Html.ImageGetter() {
        @Override
        public Drawable getDrawable(String s) {
            Drawable drawable=null;
            URL url;
            try {
                url = new URL(s);
                drawable = Drawable.createFromStream(url.openStream(), "");
            } catch (Exception e) {
                e.printStackTrace();
                return null;
            }
            drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
            return drawable;}
    };
}
